home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Interactive Reference Guide
/
C-C++ Interactive Reference Guide.iso
/
c_ref
/
csource3
/
156_01
/
args.doc
< prev
next >
Wrap
Text File
|
1985-08-21
|
2KB
|
51 lines
ARGS Library Documentation
ARGS gives the user access to the command line and optionally
redirects the standard input and/or output.
FUNCTIONS
setargs()
If access to the command line or I/O redirection is
wanted, setargs() must be called BEFORE ANY DISK I/O
IS DONE. This is because the disk operations can
overwrite the command line. setargs() parses the
command line, which is a series of items separated by
one or more spaces. A '<' followed by a file name will
redirect the standard input (used by getchar() and
gets()) to that file. A '>' followed by a file name
will similarly redirect the standard output (used by
putchar() and puts()). If the file exists, it will be
silently deleted. '>>' followed by a file name will
also redirect the standard output, but if the file
already exists then the new characters will be appended
to the existing data. In any of the above cases, one
or more spaces can appear before the file name. Items
other than the above are saved for later access by
getarg(). As far as getarg() is concerned, I/O
redirection commands are invisible. Regardless of I/O
redirection, err() will always display its message and
walkback trace (if any) on the console, putc(c,1) or
putc(c,STDERR) will always send the character c to
the console, and getc(0) will always get a character
from the keyboard.
getarg(n,s,size) int n; char *s; int size;
places in s the n-th argument. Returns s if successful
or, if there was no n-th argument, returns -1. Assumes
s has "size" bytes. The 0-th argument, which under Unix
would be the name by which the program was invoked, is
always "*".
INTERNAL DOCUMENTATION
setargs() uses alloc() to allocate its buffer.
AUTHOR
These programs were written by Jan-Henrik Johansson
(Dr. Dobb's Journal no 74 p 62) and extensively
rewritten by J. R. Van Zandt